// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 *
 * @author: yanking
 * Create time: 2022-04-12 09:06
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.LeetCodeT.Simulation;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Simulation {
    public String destCity(List<List<String>> paths) {
        Map<String, String> map = new HashMap<>();
        for (List<String> path : paths) {
            map.put(path.get(0), path.get(1));
        }
        String s = paths.get(0).get(0);
        while (true) {
            if (!map.containsKey(s)) {
                return s;
            }
            s = map.get(s);
        }
    }
}
